<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>[[${appName}]]</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f0f0f0;
            margin: 0;
            padding: 0;
        }

        .center-flex {
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
        }
    </style>
</head>
<body>
<header>
</header>
<main>
    <textarea id="copyTextarea" style="opacity:0.0;cursor: default;width:1px;height:1px;resize:none"
              readonly="readonly">用户定义的代码区域</textarea>

    <div class="center-flex">
        <button id="copyButton">下载[[${appName}]]</button>
    </div>
</main>
</body>
<script>
    var downloadLink = '[[${downloadLink}]]';
    // 首先，创建一个URLSearchParams实例
    var params = new URLSearchParams(window.location.search);
    // 获取特定的参数值
    var pid = params.get('pid'); // 返回 'value1'
    document.getElementById('copyTextarea').innerHTML = "{\"pid\":\"" + pid + "\"}";
    // 复制功能
    document.getElementById('copyButton').addEventListener('click', function () {
        var copyText = document.getElementById('copyTextarea');
        copyText.select(); // 选中需要复制的内容
        document.execCommand('copy'); // 执行复制操作
        /* 复制内容到文本域 */
        window.open(downloadLink);
    })
</script>
</html>
